<?php

declare(strict_types=1);

namespace app\model;

use think\model\concern\SoftDelete;

/**
 * 
 *
 * @mixin \think\Model
 * @property int $id
 * @property string $name
 * @property string $mobile
 * @property string $avatar 头像
 * @property string $created_at
 * @property string $updated_at
 * @property string $deleted_at
 * @property-read \app\model\DmjPlatformUsers[] $platform
 * @method static \think\db\Query onlyTrashed()
 * @method static \think\db\Query withTrashed()
 */
class DmjUsers extends CommonModel
{
    use SoftDelete;

    public function platform()
    {
        return $this->hasMany(DmjPlatformUsers::class, 'user_id');
    }

    public static function onAfterDelete($user)
    {
        DmjPlatformUsers::destroy(DmjPlatformUsers::where('user_id', $user->id)->column('id'));
    }
}
